﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using TomNet.IMSC.Core.Contracts.QandA;
using TomNet.IMSC.Web.Filters;
using TomNet.IMSC.Web.Models.ApiParams;
using TomNet.Web.Mvc.UI;
using TomNet.Web.WebApi;

namespace TomNet.IMSC.Web.Controllers.API
{
    [GlobalAuthorization]
    public class QandAInterfaceController : BaseApiController
    {
        public IQandAModelContract QandAModelContract { get; set; }
        public IQandATypeModelContract QandATypeModelContract { get; set; }



        [Description("API-百问百答")]
        public IHttpActionResult ttGetQandAInterfaceList()
        {
            var query = from qa in QandAModelContract.Entities.Where(m => !m.IsDeleted)
                        join qatype in QandATypeModelContract.Entities.Where(m => !m.IsDeleted) 
                        on qa.ProblemTypeID equals qatype.Id
                        select new QandAInterfaceListModel
                        {
                            ID = qatype.Id,
                            ProblemType = qatype.ProblemType,
                            Problem = qa.Problem,
                            Answer = qa.Answer,
                        };
            var a = query.ToList();

            var result = new AjaxResult("成功", AjaxResultType.Success, query.ToList());
            return Token(result, "");
        }
    }
}